1. Field of the Invention
The present invention relates to a method of drawing luminance of shadows of an object, generated by light, or luminance of illuminated regions formed by ambient light incoming from windows, and so forth, at high-speed and with accuracy, in rendering 3-D computer graphics.
2. Description of the Related Art
Drawing of shadows, used in 3-D computer graphics, is executed by a process whereby, with respect to all polygons lying on the back side in relation to light rays capable of casting shadows thereon, a polygon is projected on a plane that includes polygons on which shadows can be cast, lying on the front side in relation to the light rays.
With the conventional method, drawing of shadows required vector operation in an amount proportional to the square of the number of polygons as the targets of drawing. Calculations required by the vector operation are only multiplication, division, addition, and subtraction except for the time of preparing determinants for initial transformations, and loads of such multiplication, division, addition, and subtraction, as imposed on a computer, are not great.
However, since a total amount of calculations generally becomes massive, it has been a general practice to draw only shadows thrown on a plane such as the ground in the case of drawing shadows of an object due to limited time allowed for the operation at the time of interactive representation when real-time drawing is required. Hence it has been impossible to implement not only accurately casting shadows on a solid body in a complex shape in real time but also casting shadows thereon even in a pseudo manner.
Further, light rays incoming through windows, and light rays incoming indoors through transparent bodies illuminate the floor, the wall, and solid bodies in a complex shape, thereby forming illuminated regions having luminance higher than that in the surroundings. The illuminated regions are in reverse relation to shadows having luminance lower than that in the surroundings, and for the same reason as in the case of the shadows described above, it is impossible to draw the illuminated regions by means of a simple operation. It is therefore an object of the invention to draw the scope of shadows of a solid body by light and the illuminated regions of the solid body, formed by light, on a display device at high speed and with accuracy by means of a less and simple operation.
To this end, with a method according to the invention, in a process of generating a shadow Ls in 3-D computer graphics, a solid body (ABCD) is first drawn in a drawing space as a target for drawing in accordance with the Z-buffer method or a method similar thereto, and subsequently, in the course of executing the process of generating the shadow Ls with respect to a polygon (ABC) facing away from light rays L among all polygons (ABC, ACD, ADB) composing the solid body (ABCD) existing in the drawing space, the following novel steps are taken.
With the method of adjusting luminance by light at high speed in rendering 3-D computer graphics according to the invention, said process comprises the steps of:
forming a solid body (ABCPQR) as a shadow space of the polygon (ABC) by causing respective vertices (A, B, C) of the polygon (ABC) to be shifted in the vector direction of the light rays (L) to the boundary of the drawing space; and
increasing luminance within a scope of faces on the back side of the solid body (ABCPQR) as seen from the point of view (E) at the time of drawing with respect to respective faces composing the solid body (ABCPQR) by adding to the extent of a constant (K) for luminance adjustment to the luminance within the scope of the faces on the back side of the solid body (ABCPQR) while decreasing luminance within a scope of faces on the front side of the solid body (ABCPQR) as seen from the point of view (E) at the time of drawing by subtracting to the extent of the constant (K) for luminance adjustment from the luminance within the scope of the faces on the front side thereof.
As a result of the process described above, when a polygon (xcex1) does not exist in the shadow space of the solid body (ABCPQR), luminance of respective faces of the solid body (ABCPQR) is rendered to be in a state undergoing no change because of (Kxe2x88x92K=0).
Meanwhile, when the polygon (xcex1) exists in the shadow space of the solid body (ABCPQR), a drawing process by hidden surface removal is not applied to the respective faces of the solid body (ABCPQR), more backward than the polygon (xcex1) as seen from the point of view (E) at the time of drawing, thereby not rendering luminance in a region of hidden surface removal brighter by the constant value (K.). Accordingly, there will be executed a process of rendering luminance within the scope of a face of the solid body ABCPQR, lying in a forward position of the polygon (xcex1) as seen from the point of view (E), that is, the front face thereof as seen from the point of view (E), subtracted consequentially by the constant value (K), so that there will be created a state equivalent to that where the shadow (Ls) of the polygon (ABC) is projected on the polygon (xcex1) from the viewpoint of representation.
Thus, it follows that the shadow (Ls) of the polygon (ABC) can be drawn on the polygon (xcex1) in the solid body (ABCPQR) as the shadow space at high speed and with accuracy by simple calculation for luminance adjustment.
Further, when a plurality of polygons a exist in the solid body ABCPQR as the shadow space, luminance adjustment is executed in the order of the back side to the front side as seen from the point of view (E) and a range of luminance adjustment is limited to one stage, so that if the range of the luminance adjustment exceeds the stage, a subtrahend value of luminance is limited to the constant value (K) only. As a result, luminance within the scope of the shadow (Ls) is not decreased more than necessary.
In the case where the point of view (E) lies within the solid body (ABCPQR) as the shadow space, and the front face thereof in relation to the point of view (E) does not exist, processing is executed exceptionally as a case of the front face being in a state covering the field of vision. As a result, it becomes possible to execute the same shadow generation process as described above even in such a special condition as described above.
In the case where the shadow (Ls) is cast on both polygons (xcex1), adjacent to each other, respectively, within the solid body (ABCPQR) as the shadow space, processing of the shadow (Ls) of a side shared by both the polygons (xcex1) is omitted, thereby shortening an operation time.
When a polygon ABC which is a shaded face interferes with a solid body EFGSTU as a shadow space of the other polygon EFG, a decrease in luminance of the polygon ABC which is the shaded face, caused by the shadow generation process applied to the other polygon EFG, can be prevented by prohibiting a change of luminance with respect to the polygon ABC which is the shaded face after processing of the shaded face in a stage where drawing of the solid body (ABCD) is completed, thereby enabling a drawing state of the solid body (ABCD) to be preserved at an initial luminance value.
As previously described, light rays (L) incoming through windows, transparent bodies, and so forth illuminate the floor, the wall, the ceiling, and other solid bodies in a complex shape, thereby forming an illuminated region (Li) having luminance higher than that in the surroundings. The illuminated region (Li) is in a reverse relation to the shadows (Ls) having luminance lower than that in the surroundings.
Assuming that the polygon (ABC) is a window or a transparent body in the course of drawing the previously-described shadow (Ls), the solid body (ABCPQR) is regarded as an illuminated space of the incoming light rays (L). If luminance adjustment is applied to respective faces of the solid body (ABCPQR) as the illuminated space by designating the respective faces with the positive sign and the negative sign, respectively, contrary to those in the case of drawing the shadow (Ls), it is possible to draw the illuminated region (Li) having luminance higher than that in the surroundings on a polygon xcex1 at high speed and with accuracy by the light rays (L) incoming through the windows, and transparent bodies.
More specifically, in accordance with a second aspect of the invention, in a process of generating an illuminated region (Li) by light rays (L) in 3-D computer graphics, a solid body (ABCD) is first drawn in a drawing space as a target for drawing according to the Z-buffer method or a method similar thereto, and subsequently, in the course of executing the process of generating the illuminated region (Li) with respect to a polygon (ABC) allowing the light rays (L) to pass therethrough among all polygons composing the solid body existing in the drawing space, the following novel steps are taken.
With a method of adjusting luminance by light at high speed in rendering 3-D computer graphics according to the invention, said process comprises the steps of:
forming a solid body (ABCPQR) as an illuminated space, formed by the polygon (ABC), by shifting respective vertices (A, B, C) of the polygon (ABC) in the vector direction of the light rays (L) to the boundary of the drawing space; and
decreasing luminance within a scope of faces on the back side of the solid body (ABCPQR) as seen from the point of view (E) at the time of drawing with respect to respective faces composing the solid body (ABCPQR) by subtraction to the extent of a constant (K) for luminance adjustment, while increasing luminance within a scope of faces on the front side of the solid body (ABCPQR) as seen from the point of view (E) at the time of drawing by addition to the extent of the constant (K) for luminance adjustment.
As a result of a luminance addition process or a luminance subtraction process, when a polygon (xcex1) does not exist in the illuminated space of the solid body (ABCPQR), luminance of respective faces of the solid body (ABCPQR) is rendered to be in a state undergoing no change because of (Kxe2x88x92K=0). Meanwhile, when the polygon (xcex1) exists in the illuminated space of the solid body (ABCPQR), a drawing process by hidden surface removal is not applied to the respective faces of the solid body (ABCPQR), more backward than the polygon (xcex1) as seen from the point of view (E) at the time of drawing, thereby not rendering luminance in a region of hidden surface removal to become darker by the constant value (K.), so that there is executed a process of rendering luminance within the scope of a face of the solid body ABCPQR, lying in a forward position of the polygon (xcex1) as seen from the point of view (E), that is, the front face thereof as seen from the point of view (E), added by the constant value (K) in consequence, creating a state equivalent to that where the illuminated region (Li) formed by the polygon (ABC) is projected on the polygon (xcex1) from the viewpoint of representation.
Thus, the illuminated region (Li) of the light rays (L) from the polygon (ABC) can be drawn on the polygon (xcex1) in the solid body (ABCPQR) as the illuminated space at high speed and with accuracy by simple calculation for luminance adjustment.
When a plurality of polygons a exist in the solid body ABCPQR as the illuminated space, luminance adjustment is executed in the order of the front side to the back side as seen from the point of view (E) and a range of luminance adjustment is limited to one stage, and if the range of the luminance adjustment exceeds the stage, an addend value of luminance is limited to the constant value (K) only, thereby preventing luminance in the scope of the illuminated region (Li) from increasing higher than necessary.
In the case where the point of view (E) lies within the solid body (ABCPQR) as the illuminated space, and the front face thereof in relation to the point of view (E) does not exist, processing is executed exceptionally as a case of the front face being in a state covering the field of vision. As a result, it becomes possible to execute the same process for the illuminated region (Li) as described above even in such a special condition as described above.
In the case where the illuminated region (Li) occurs to both polygons (xcex1), adjacent to each other, respectively, within the solid body (ABCPQR) as the illuminated space, processing of the illuminated region (Li) of a side shared by both the polygons (xcex1) is omitted, thereby shortening an operation time.
When the polygon (ABC) interferes with a solid body (EFGSTU) as an illuminated space of the other polygon (EFG) allowing light rays (L) to pass therethrough, an increase in luminance of the polygon (ABC), caused by processing of the illuminated region (Li) of the other polygon EFG, is prevented by prohibiting change of luminance with respect to the polygon (ABC) after processing of luminance thereof in a stage where drawing of a solid body (ABCD) is completed, so that the drawing state of the solid body (ABCD) at the initial luminance value can be preserved.